package com.josework.springhelloworld.model.processer;

import java.util.function.Function;
import java.util.function.UnaryOperator;

public class ProcessingTest {
    public static void main(String[] args) {
        ProcessingObject<String> p1 = new HeaderTextProcessing();
        ProcessingObject<String> p2 = new SpellCheckerProcessing();
        p1.setSuccessor(p2);
        String res = p1.handle("Aren't labdas really sexy?!!");
        System.out.println(res);

        //lambda 表达式实现
        UnaryOperator<String> headerProcessing =
                (String text) -> "From Raoul, Mario and Alan: " + text;
        UnaryOperator<String> spellCheckerProcessing =
                (String text) -> text.replace("labda", "lambda");
        Function<String,String> pipeline =
                headerProcessing.andThen(spellCheckerProcessing);
        String result = pipeline.apply("Aren't labdas really sexy?!!");


    }
}
